<?php

class Admini_PackageNoController extends Uuch_ManageController {

      public function init() {
            $this->appendCss('/css/home/warehouse.css');
            $this->appendCss('/admins/css/common.css');
            $this->appendScript('/admins/js/jquery/jquery-1.7.2.min.js')->appendScript('/js/jquery.validate.min.js')->appendScript('/js/messages_cn.js')->appendScript('/js/uuch.js');
            parent::init();
            $this->view->type = "autotask";
      }

      public function indexAction() {
            $this->setTitle('扫描订单');
            $this->view->conse = 0;
            $shipItem = Application_Model_shipType::getAll();
            $this->view->shipAll = $shipItem;
            if ($this->isPost()) {
                  $packageItem = new Application_Model_PackageList();
                  $packageItem->expressId = $this->getSafeParam('comname');
                  $packageItem->content = str_replace("\r", '', str_replace("\n", '', nl2br($this->getSafeParam('barcode2'))));
                  if ($packageItem->content) {
                        $packageItem->dateCreated = $this->now();
                        $packageItem->operator = Uuch_Util::getUserNikeName();
                        $packageItem->save();
                        $this->view->conse = $packageItem->setOne();
                        $this->view->id = $packageItem->id;
                  }
            }
      }

      public function tabletAction() {
            //$this->view->type = 'storelocation';
            $this->view->stype = 2;
            $this->_helper->layout->disableLayout();
            $shipItem = Application_Model_shipType::getAll();
            $this->view->shipAll = $shipItem;
      }

      public function dreprintAction() {
            $this->disableLayout();
            $count = $this->_getParam('count');
            $result = Application_Model_PackageNo::getbyrecount($count);
            //给视图传数组
            $this->view->packageNolist = $result;
            $this->view->userall = $result;
      }

      public function printAction() {
            $this->disableLayout();
            $count = $this->_getParam('count');
            $result = Application_Model_PackageNo::getbyrecount($count);
            //给视图传数组
            $this->view->packageNolist = $result;
            $this->view->userall = $result;
      }

      public function relistAction() {
            $this->setTitle('扫描列表');
            $pagesize = 15;
            $pageindex = $this->_getParam('start');
            if (!$pageindex) {
                  $pageindex = 0;
            }
            $quick = $this->_getParam('quick');
            $result = Application_Model_PackageList::getPageFilter($quick, $pagesize, $pageindex);
            $this->view->packagelist = $result['list'];
            $this->view->packageall = $result;
            $stime = $this->_getParam('starttime');
            if ($stime) {
                  $result = Application_Model_PackageList::getbytime($stime, $pagesize, $pageindex);
                  $this->view->packagelist = $result['list'];
                  $this->view->packageall = $result;
            }
      }

      public function listAction() {
            $this->settitle('条码列表');
            //后台管理页，包括分页，和循环输出
            $pagesize = 15;
            $pageindex = $this->_getParam('start');
            if (!$pageindex) {
                  $pageindex = 0;
            }
            $count = $this->_getParam("count");
            $result = Application_Model_PackageNo::getbycount($count, $pagesize, $pageindex);
            $this->view->trackList = $result["list"];
            $package = Application_Model_PackageNo::getPackageOperator($count);
            $this->view->name = $package->operator;
      }

      public function detailAction() {
            $count = $this->_getParam("id");
            $result = Application_Model_PackageList::load($count);
            $this->view->detailList = $result;
      }

}
